package com.example.springboot.config.resttemplateconfig;

import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;

import java.io.IOException;

/**
 * RestTemplate拦截器的配置
 *
 * @Author:ChenZhangKun
 * @Date: 2022/9/5 15:46
 */
public class RestTemplateInterceptor implements ClientHttpRequestInterceptor {
    @Override
    public ClientHttpResponse intercept(HttpRequest httpRequest, byte[] bytes, ClientHttpRequestExecution clientHttpRequestExecution) throws IOException {
        httpRequest.getHeaders().set("czk", "czk");
        return clientHttpRequestExecution.execute(httpRequest, bytes);
    }
}
